package com.zcb.qingshoudan.fragment;

import android.annotation.SuppressLint;
import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.Toast;

import com.zcb.qingshoudan.R;
import com.zcb.qingshoudan.gridview.MyGridAdapter;
import com.zcb.qingshoudan.gridview.MyGridView;

/**
 * Created by admin on 2016/11/23.
 */
@SuppressLint("ValidFragment")
public class HomePageFragment extends Fragment {

    private MyGridView myGridView;
    private IFragment iFragment;
    private Context mContent;
//    private String[] img_text= { "微信收银", "支付宝收银", "百度收银", "信用卡还款", "淘宝电影", "彩票",
//            "当面付", "亲密付", "机票", };
    private String[] img_text= { "微信收银", "支付宝收银", "百度收银", "卡券核销", "收款记录", "核销记录",
            "收款统计", "商户信息", "修改密码", };
    private int[] imgs= { R.drawable.main_icon_wxsy, R.drawable.main_icon_zfbsy,
            R.drawable.main_icon_bdsy, R.drawable.main_icon_kqhx,
            R.drawable.main_icon_skjl, R.drawable.main_icon_hxjl,
            R.drawable.main_icon_sktj, R.drawable.main_icon_shxx, R.drawable.main_icon_xgmm };


    public HomePageFragment(Context mContent,IFragment iFragment) {
        this.mContent = mContent;
        this.iFragment=iFragment;
    }
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_homepage,container,false);

        myGridView= (MyGridView) view.findViewById(R.id.homepage_favorViewPager);
        myGridView.setAdapter(new MyGridAdapter(mContent,img_text,imgs));
        initEvent();
        return view;
    }
    private void initEvent(){
        myGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Toast.makeText(mContent,"info:"+img_text[i],Toast.LENGTH_SHORT).show();
            iFragment.openAty(i);
            }
        });
    }
}
